package cn.edu.scau.cmi.chenbingquan.composite.safe;

import java.util.ArrayList;

// 安全组合模式的组合节点
public class SafeComposite extends SafeComponent {
	private ArrayList<SafeComponent> children = new ArrayList<>();
	
	public SafeComposite(String name) {
		this.name = name;
	}
	
	// 增加子节点
	public void addChild(SafeComponent child) {
		children.add(child);
	}
	
	// 删除子节点
	public void removeChild(SafeComponent child) {
		children.remove(child);
	}
	
	// Treeitem显示的是节点的toString方法的返回值
	@Override
	public String toString() {
		return "团队：" + this.name;
	}
	
	// 访问器与修改器
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ArrayList<SafeComponent> getChildren() {
		return children;
	}
}
